﻿using System;
using System.Collections.Generic;
using UnityEngine;
using Yoozoo.Framework.Core;
using Yoozoo.Managers.ResourceManagerV2.Runtime;

namespace Gameplay.PVE.Survivor
{
    public static class BattleConstValue
    {
        public static readonly Dictionary<int,string> heroModelNameMap = new Dictionary<int, string>()
        {
            {41000,"Hero1"},
            {410001,"Hero1"},
            {41001,"survivor_hero_41001"},
            {41002,"survivor_hero_41002"},
            {41003,"survivor_hero_41003"},
            {41004,"survivor_hero_41004"},
            {43001,"survivor_npc_Police_Riot"},
            {43002,"survivor_npc_Police_Sm"},
            {43003,"survivor_npc_Police_Swat"},
            {43004,"survivor_npc_Police_Bo"},
            {43005,"survivor_npc_Police_FatPolice"},
            {43006,"survivor_npc_Police_Stick"},
            {43007,"survivor_npc_Police_StickShield"},
            {43008,"survivor_npc_Police_HG"},
            {43009,"survivor_npc_Police_HGShield"},

            {42001,"survivor_npc_gangster_Sg"},
            {42002,"survivor_npc_gangster_Smg"},
            {42003,"survivor_npc_gangster_Ar"},
            {42004,"survivor_npc_gangster_Rf"},
            {42005,"survivor_npc_gangster_ArBo"},
            {42006,"survivor_npc_gangster_Stick"},
            {420061,"survivor_npc_gangster_Stick_Chair"},
            {420062,"survivor_npc_gangster_Stick_Chuizi"},
            {420063,"survivor_npc_gangster_Stick_Guitar"},
            {42007,"survivor_npc_gangster_Boxing"},
            {420071,"survivor_npc_gangster_Boxing_Gloves"},
            {42008,"survivor_npc_gangster_Knife"},
            {420081,"survivor_npc_gangster_Knife_Chanzi"},
            {420082,"survivor_npc_gangster_Knife_Chuaizi"},
            {42009,"survivor_npc_gangster_Knife_Crowbar"},
            {42010,"survivor_npc_gangster_DoubleSmg"},
            {42011,"survivor_npc_gangster_Bomb"},
            {42021,"survivor_boss_gangster_Smg"},

            {51001,"survivor_boss_gangster_DoubleSmg"},
            {51002,"survivor_boss_41005"},
            {51003,"survivor_boss_41007"},
            {51004,"survivor_boss_41021"},
            {51005,"survivor_boss_41019"},
            {51006,"survivor_boss_41012"},
            {51007,"survivor_boss_41004"},
            {51008,"survivor_boss_fatpolice"},
            //npc
            {300001,"survivor_npc_bankworker_01"},
            {300002,"survivor_npc_walker_01"},
            {300003,"survivor_npc_walker_02"},
            {300004,"survivor_npc_walker_03"},
            {300005,"survivor_npc_walker_04"},
            {300006,"survivor_npc_walker_beauty"},
            {300007,"survivor_npc_41004"},
            
            {61001,"mesh_rpg_truck_01"},
            {61002,"Survivor_Obstacle_BMW"},
            {61003,"Survivor_Obstacle_Chevrolet"},
            {61004,"Survivor_Obstacle_Ferrari"},
            {61005,"Survivor_Obstacle_Rolls"},
            {61006,"Survivor_Obstacle_Lambo"},
            {61007,"Survivor_Truck_Landrover"},
        };

        public static float UnitCollisionRadius = 0.5f;
        public static readonly Vector3 DEFAULT_POINT = new Vector3(-999, -999, -999);

        public static string LightElementMark = "survivorIndoorScene";

        public static int SurvivorRayLayer = LayerMask.NameToLayer("SurvivorRay");
        public static int SurvivorObstacleLayer = LayerMask.NameToLayer("SurvivorObstacle");
        public static int SurvivorRoadBlockLayer = LayerMask.NameToLayer("Ragdoll");
        public static int SurvivorDeckLayer = LayerMask.NameToLayer("commander1");

        public static int SkillEffectCommon = 5021;

        private static List<Vector3> deckHeroPositions = new List<Vector3>
        {
            new Vector3(0f, 0, 0),
            new Vector3(-1.5f, 0, -1.5f),
            new Vector3(1.5f, 0, -1.5f),
            new Vector3(1.5f, 0, 1.5f),
            new Vector3(-1.5f, 0, 1.5f),
        };
        
        private static Dictionary<int,string> deckCircleAnimationResIdMap = new Dictionary<int, string>
        {
            {0,"ani_sfx_buzheng_resid_has_hero"},
            {3,"ani_sfx_buzheng_resid_has_hero_lan"},
            {4,"ani_sfx_buzheng_resid_has_hero_zi"},
            {6,"ani_sfx_buzheng_resid_has_hero_hong"},
            {7,"ani_sfx_buzheng_resid_has_hero_hong"},
        };
        
                
        private static Dictionary<int,string> deckCircleAnimationPlaceMap = new Dictionary<int, string>
        {
            {0,"ani_sfx_buzheng_place"},
            {3,"ani_sfx_buzheng_place_lan"},
            {4,"ani_sfx_buzheng_place_zi"},
            {6,"ani_sfx_buzheng_place_hong"},
            {7,"ani_sfx_buzheng_place_hong"},
        };
        
        private static Dictionary<int,string> deckCircleAnimationDownMap = new Dictionary<int, string>
        {
            {0,"ani_sfx_buzheng_down"},
            {3,"ani_sfx_buzheng_down_lan"},
            {4,"ani_sfx_buzheng_down_zi"},
            {6,"ani_sfx_buzheng_down_hong"},
            {7,"ani_sfx_buzheng_down_hong"},
        };
        
        private static Dictionary<int,string> deckCircleAnimationChangeMap = new Dictionary<int, string>
        {
            {0,"ani_sfx_buzheng_change"},
            {3,"ani_sfx_buzheng_change_lan"},
            {4,"ani_sfx_buzheng_change_zi"},
            {6,"ani_sfx_buzheng_change_hong"},
            {7,"ani_sfx_buzheng_change_hong"},
        };
        
        public static List<Vector3> GetDeckHeroPositions()
        {
            return deckHeroPositions;
        }
        
        public static string GetDeckCircleAnimationResId(int rare)
        {
            if (deckCircleAnimationResIdMap.TryGetValue(rare, out var name))
            {
                return name;
            }
            return deckCircleAnimationResIdMap[0];
        }
        
        public static string GetDeckCircleAnimationPlace(int rare)
        {
            if (deckCircleAnimationPlaceMap.TryGetValue(rare, out var name))
            {
                return name;
            }
            return deckCircleAnimationPlaceMap[0];
        }
        
        public static string GetDeckCircleAnimationDown(int rare)
        {
            if (deckCircleAnimationDownMap.TryGetValue(rare, out var name))
            {
                return name;
            }
            return deckCircleAnimationDownMap[0];
        }
        
        public static string GetDeckCircleAnimationChange(int rare)
        {
            if (deckCircleAnimationChangeMap.TryGetValue(rare, out var name))
            {
                return name;
            }
            return deckCircleAnimationChangeMap[0];
        }
        
        private static List<Vector3> teamPositions = new List<Vector3>
        {
            new Vector3(0f, 0, 0),
            new Vector3(-0.85f, 0, -0.85f),
            new Vector3(0.85f, 0, -0.85f),
            new Vector3(0.85f, 0, 0.85f),
            new Vector3(-0.85f, 0, 0.85f),
        };

        public static Vector3 GetTeamPosition(int index,int totalCount)
        {
            if (index >= teamPositions.Count)
            {
                var extraCount = totalCount - teamPositions.Count + 1;
                var extraIndex = index - teamPositions.Count;
                var teamRadius = 2.5f;
                var x = 0f;
                var z = 0f;
                if (extraCount == 1)
                {
                    x = Mathf.Sin(0) * teamRadius;
                    z = Mathf.Cos(0) * teamRadius;
                }
                else
                {
                    var angle = 360f / extraCount * extraIndex;
                    x = Mathf.Sin(Mathf.Deg2Rad * angle) * teamRadius;
                    z = Mathf.Cos(Mathf.Deg2Rad * angle) * teamRadius;
                }
                return new Vector3(x, 0, z);
            }
            else
            {
                return teamPositions[index];
            }
        }

        private static HashSet<string> fullBodyTriggerMap = new HashSet<string>
        {
            "Fullbody_Skill_Storage",
            "Fullbody_Skill",
            "Fullbody_Fire_Storage",
            "Fullbody_Fire",
            "KnockFlyStart",
            "KnockFlyEnd",
        };
        
        public static bool IsFullBodyTrigger(string triggerName)
        {
            return fullBodyTriggerMap.Contains(triggerName);
        }

        private static HashSet<int> lockSelfHpLevel = new HashSet<int>
        {
            1001,
            1002,
            1003,
        };
        public static bool IsLockSelfHp(int levelId)
        {
            return lockSelfHpLevel.Contains(levelId);
        }
    }
}
